package com.qianchang.microfinance.view.credit.data;

import android.os.Bundle;
import android.os.CountDownTimer;
import android.view.View;
import com.dm.library.widgets.element.DTextView;
import com.qianchang.microfinance.R;
import com.qianchang.microfinance.bean.FindUserBasicInfoBean;
import com.qianchang.microfinance.global.ConstantAppInfo;
import com.qianchang.microfinance.view.base.BaseActivity;
import com.qianchang.microfinance.view.hsdialog.CommunicationServiceDialog;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

import static com.qianchang.microfinance.global.ConstantAppInfo.DEFAULT_TIME;

/**
 * Created by SSC on 2017/12/27.
 *
 *  手机认证 输入短信验证码页面
 *
 */

public class PhoneAuthMsgCodeActivity extends BaseActivity{

    @BindView(R.id.tv_get_msg_code)
    DTextView tvmsgCode;
    private CountDownTimer phoneDownTimer;



    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_phoneauthmsgcode_layout);
        ButterKnife.bind(this);
        initView();
        initData();

    }

    @Override
    protected void initView() {
        super.initView();
        String title = getString(R.string.phone_auth);
        setTitle(title);

    }

    @Override
    protected void initData() {
        super.initData();
    }

    private void refreshView() {

    }


    private FindUserBasicInfoBean basicInfoBean;
    public static final int BASIC_INFO = 100;

    @OnClick({R.id.bt_next_id,R.id.tv_get_msg_code})
    public void onViewClicked(View view){
        switch (view.getId()) {
            case R.id.bt_next_id:

                startActivity(GoSesameAuthorizedActivity.class,true);

                break;
            case R.id.tv_msgforgetpsw_id:
                CommunicationServiceDialog.newInstance().show(getSupportFragmentManager(), "commdialog");

                break;
            case R.id.tv_get_msg_code:          //获取验证码
                showRemainTime();

                break;
            default:
                break;
        }
    }

    //显示获取手机验证码倒计时
    private void showRemainTime() {
        tvmsgCode.setEnabled(false);
        phoneDownTimer = new CountDownTimer(DEFAULT_TIME, 1000) {
            @Override
            public void onTick(long millisUntilFinished) {
                int temp = (int) (millisUntilFinished / 1000);
                tvmsgCode.setText(temp + "S倒计时");                              //getString(R.string.remain_time) +
                tvmsgCode.setEnabled(false);
            }

            @Override
            public void onFinish() {
                tvmsgCode.setText(getString(R.string.btn_get_verify_code));
                tvmsgCode.setEnabled(true);
            }
        }.start();
    }



}
